package cn.action;

import java.util.List;

import cn.biz.ConfigurationBiz;
import cn.entity.Configuration;

import com.opensymphony.xwork2.Action;

public class ConfigurationAction implements Action {
	private ConfigurationBiz configurationBiz;
	private List<Configuration> Clist;
	private Configuration configuration;
	private String resultStr;
	
	public ConfigurationBiz getConfigurationBiz() {
		return configurationBiz;
	}

	public void setConfigurationBiz(ConfigurationBiz configurationBiz) {
		this.configurationBiz = configurationBiz;
	}

	public List<Configuration> getClist() {
		return Clist;
	}

	public void setClist(List<Configuration> clist) {
		Clist = clist;
	}

	public Configuration getConfiguration() {
		return configuration;
	}

	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}

	public String getResultStr() {
		return resultStr;
	}

	public void setResultStr(String resultStr) {
		this.resultStr = resultStr;
	}

	//后台显示全部关键字
	public String keywordManageShow() {
		Clist = configurationBiz.getAll();
		return SUCCESS;
	}
	
	//跳转到新增关键字页面
	public String keywordManageAdd() {
		configuration = new Configuration();
		return SUCCESS;
	}
	
	//跳转到编辑关键字页面
	public String keywordManageView() {
		Integer id = configuration.getId();
		configuration = configurationBiz.getConfigurationById(id);
		return SUCCESS;
	}
	
	//保存编辑关键字信息
	public String keywordManageEdit() {
		try {
			configurationBiz.insertOrUpdate(configuration);
			resultStr = "{\"flag\":\"success\"}";
		} catch (Exception e) {
			e.printStackTrace();
			resultStr = "{\"flag\":\"error\"}";
		}
		return SUCCESS;
	}
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
}
